<?php
/**
 * Joomla! 1.6 component WoWRoster
 */
// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

include_once (dirname(__FILE__).DS.'page_display.php');
$document = & JFactory :: getDocument();

// Plugins
$ginfo = getGuildInfo();
foreach ( $ginfo as $config )
{
}
list($region, $locale) = explode('-',$config->lang);

	$db =& JFactory::getDBO();
	$query = "SELECT * FROM ".$db->nameQuote('#__guild_guilds')." WHERE `guild_name` = '$config->name' AND `server` = '$config->realm'";
	$db->setQuery($query);
	$row = $db->loadAssoc();
	//update time to time() unix value
	$updatetime = (($config->update_hours * 60) * 60);
	$currenttime = time();
	if (($row['update_time'] + $updatetime) < $currenttime)
	{
		jimport('armorysuite.smart.drops');
		$api = new WowAPI($config->region);

		$guild = $api->Guild->getGuildInfo($config->realm,$config->name,'members');
		$gupdate = new apiguildUpdate;
		$gupdate->update_guild($guild,$config->region);
	}
	else
	{
		echo 'no update needed<br>';
	}
	
echo 'I display the members list!';
displayRoster($row['guild_id']);


?>